import { PullToRefresh } from "antd-mobile"
import { sleep } from "antd-mobile/es/utils/sleep"
import React, { useEffect, useState } from "react"
import { httpJson } from "../../../../services/http"
import NormalCard from '../components/normal-card'

const DoneList:React.FC = () => {
    const [list,setList] = useState<any>([])
    const [loading, setLoading] = useState<boolean>(false)
    const getMerchantOrderList = async () => {
        setLoading(true)
        httpJson('GET','/api/order/getMerchantOrderList', {orderStatus: '2'})
        .then((res: any)=>{
          setList(res.data.data)
          setLoading(false)
        })
        .catch(err => {
          console.log(err)
          setLoading(false)
        })
    }
    useEffect(() => {
        getMerchantOrderList()
      },[])
    return(
        <PullToRefresh
            onRefresh={getMerchantOrderList}
        >
            {
                list && list.length > 0 &&
                list.map((item: any) => {
                    return <NormalCard currentKey="3" props={item} />
                })
            }
            {
                !loading && !list.length && (
                    <p style={{maxHeight: 800, minHeight: 600, textAlign:'center', fontSize: 20, color: '#999', lineHeight:20}}>暂无数据...</p>
                )
            }
        </PullToRefresh>
    )
}

export default DoneList